package org.firefly.fx.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;

public class MatchUtil {

	/**
	 * 验证手机号是否正确
	 * @param Mobile
	 * @return boolean
	 */
	public static boolean isMobile(String mobile) {
		if(StringUtils.isBlank(mobile)) return false;
		Pattern p = Pattern.compile("^[1][3,4,5,8][0-9]{9}$");
		Matcher m = p.matcher(mobile);
		return m.matches();
	}
	
	/**
	 * 验证邮箱是否正确
	 * @param email
	 * @return boolean
	 */
	public static boolean isEmail(String email) {
		if(StringUtils.isBlank(email)) return false;
		Pattern p = Pattern.compile("^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$");
		Matcher m = p.matcher(email);
		return m.matches();
	}
	
}
